//数据模拟，当后端还没完成数据处理时，根接口文档来模拟数据的接收
const Mock = require("mockjs");
console.log(Mock);
// mock里的方法必须小写
Mock.mock("/news/article", "get", () => {
  return {
    state: "ok",
    data: {
      title: "这是新闻",
      content: "这是新闻的内容",
    },
  };
});  

Mock.mock("http://www.baidu.com/api", "get", () => {
  let hotLevel = new Array(parseInt(Math.random() * 10 + 1)).fill("★").join("");
  return {
    state: "ok",
    data: {
      hotLevel: hotLevel,
      title: "这是新闻",
      content: "这是新闻的内容",
      title: Mock.Random.ctitle(1, 5),
      category: Mock.Random.cword(1, 5),
      newsLink: Mock.Random.url(),
      anthor: Mock.Random.cname(),
      province: Mock.Random.province(),
      city: Mock.Random.city(),
    },
  };
});

// 导航列表
Mock.mock("http://api.cpengx.cn/finance/api/nav/navList", "get", () => {
  return {
    msg: "ok",
    result: [
      { title: "大盘行情", imgSrc: "./imgs/nav1.png", linkto: "" },
      { title: "股票组合", imgSrc: "./imgs/nav2.png", linkto: "" },
      {
        title: "股票开户",
        imgSrc:
          "https://xavatar.imedao.com/community/default/avatar.png!180x180.png",
        linkto: "",
      },
      { title: "选股攻略", imgSrc: "./imgs/nav4.png", linkto: "" },
      { title: "指数选基", imgSrc: "./imgs/nav5.png", linkto: "" },
      { title: "基金组合", imgSrc: "./imgs/nav6.png", linkto: "" },
      { title: "私募基金", imgSrc: "./imgs/nav7.png", linkto: "" },
      { title: "基金必看", imgSrc: "", linkto: "" },
    ],
  };
});
